﻿import flash.external.*
var yuan:Array = new Array();

var obj_list:Array = new Array();
var obj_posx:Array  = new Array();
var obj_posy:Array  = new Array();
var obj_color:Array  = new Array();
var obj_id:Array  = new Array();
var sum:Number = 0;
var wupin_item:Array = new Array();
var jineng_item:Array = new Array();
var wupin:Array = new Array();
var jineng:Array = new Array();
var wupin_text:Array  = new Array();
var jineng_text:Array  = new Array();
wupin_text = ["","","","","",""];
wupin_item = [wupin0,wupin1,wupin2,wupin3,wupin4,wupin5];
jineng_item = [jineng0,jineng1,jineng2,jineng3,jineng4,jineng5];
wupin = [wp0,wp1,wp2,wp3,wp4,wp5];
jineng= [jn0,jn1,jn2,in3,jn4,jn5];

//hei : 黑血条
function hp_jian(hp:Number){  //参数是 减血百分比
	hei._height =hp11._height/100 * hp;
}
function draw_map(){
	for (var i:Number = 0; i< obj_posx.length; i++){
		x = obj_posx[i]
		y = obj_posy[i]
		c = obj_color[i]

		mc = _root.createEmptyMovieClip("yuan"+i.toString(), i);
		if (obj_list.length <= i)
			obj_list.push(mc);
		obj_list[i].lineStyle(3,c);
		obj_list[i].moveTo(x,y);
		obj_list[i].lineTo(x+1,y+1);
		obj_list[i]._alpha = 100;
	}
	if (obj_list.length > obj_posx.length){
		for (var i:Number = obj_posx.length; i< obj_list.length; i++){
			obj_list[i]._alpha = 0;
		}
	}
}
//------------------------------物品---------------------
function add_wupin(i_wpin:Number,s_wp:String,num:Number,i_text:String){
    //var jz = "wuqi"+i_wp;
	//wupin_item[i_wpin].attachMovie(jz,"it",getNextHighestDepth());
	wupin[i_wpin].source = s_wp;
	wupin_item[i_wpin].label = num;
	wupin_item[i_wpin].disabled = false;
	wupin_text[i_wpin] = i_text;
	wupin_item[i_wpin].addEventListener("click",
	function(){
		wupin_item[i_wpin].doubleClickEnabled=true;
		ExternalInterface.call("tgame_mgr.wupin_click",i_wpin);
		});
	
	wupin_item[i_wpin].addEventListener("doubleClick",
	function(){


		del_wupin(i_wpin);
		ExternalInterface.call("tgame_mgr.wupin_double",i_wpin);
		}); 
	
	wupin_item[i_wpin].addEventListener("rollOver",
	function(){
		if (wupin_item[i_wpin].label =="")
			return;
		//if (textpanel.text == "")
			//ExternalInterface.call("tgame_mgr.set_text",i_wpin);
		if((textpanel._width + wupin_item[i_wpin]._x) > 1024){
			textpanel._x = (wupin_item[i_wpin]._x+wupin_item[i_wpin]._width) - textpanel._width;
		}else{
			textpanel._x = wupin_item[i_wpin]._x;
		}
		textpanel._y =  wupin_item[i_wpin]._y - 5 - textpanel._height;

		textpanel.text =wupin_text[i_wpin];
		textpanel.visible = true; 
	});
	
	wupin_item[i_wpin].addEventListener("rollOut",
	function(){
		textpanel.visible = false;
		textpanel.text = "";
		//ExternalInterface.call("tgame_mgr.wupin_click");
	});
}

function del_wupin(i:Number){
	//wupin_item[i].attachMovie("wupin","it",getNextHighestDepth());
	//wupin_item[i]._alpha = 60;
	wupin_item[i].label = "";
	wupin_item[i].doubleClickEnabled=false;
	wupin_item[i].disabled = true;
	wupin[i].source = "";
	textpanel.visible = false;
}
function set_wupin_num(i:Number,num:Number)
{
	wupin_item[i].label = num;
}
function set_wupin_text(i:Number,i_text:String){
	wupin_text[i] = i_text;
}
//--------------------技能-----------------
function add_jineng(i_jit:Number,s_jn:String,num:Number,i_text:String){
    //var jz = "jineng"+i_jneng;
	//jineng_item[i_jit].attachMovie(jz,"it",getNextHighestDepth());
	jineng[i_jit].source = s_jn;
	jineng_item[i_jit].label = num;
	jineng_item[i_jit].disabled = false;
	
	jineng_item[i_jit].addEventListener("click",
	function(){
		jineng_item[i_jit].doubleClickEnabled=true;
		ExternalInterface.call("tgame_mgr.jineng_click");
		});
	
	jineng_item[i_jit].addEventListener("doubleClick",
	function(){
		del_jineng(i_jit);
		ExternalInterface.call("tgame_mgr.jineng_double");
		}); 
	
	jineng_item[i_jit].addEventListener("rollOver",
	function(){
		if (jineng_item[i_jit].label =="")
			return;
		//if (textpanel.text == "")
			//ExternalInterface.call("tgame_mgr.set_text",i_jit);
		if((textpanel._width + jineng_item[i_jit]._x) > 1024){
			textpanel._x = (jineng_item[i_jit]._x+jineng_item[i_jit]._width) - textpanel._width;
		}else{
			textpanel._x = jineng_item[i_jit]._x;
		}
		textpanel._y =  jineng_item[i_jit]._y - 5 - textpanel._height;

		textpanel.text = jineng_text[i_jit];
		textpanel.visible = true; 
	});
	
	jineng_item[i_jit].addEventListener("rollOut",
	function(){
		textpanel.visible = false;
		textpanel.text = "";
	});
}

function del_jineng(i:Number){
	//jineng_item[i].attachMovie("wupin","it",getNextHighestDepth());
	//jineng_item[i]._alpha = 60;
	jineng_item[i].label = "";
	jineng_item[i].doubleClickEnabled=false;
	jineng_item[i].disabled = true;
	jineng[i].source = "";
	textpanel.visible = false;
}
function set_jineng_num(i:Number,num:Number)
{
	jineng_item[i].label = num;
}
function load_restmm(){
	loudou.source = "loudou.swf";
}
function remove_restmm(){
	loudou.source = "";
}
function load_wq_now(s:String){
	zb_wuqi.source=s;
}

//hp_jian(50);

//wupin_text[0] = "发法术";
//add_wupin(0,"awp.png",100);
//restmm();
//loudou.source = "";
//FramerateThrottler.initialize(2);
//FramerateThrottler.enabled = false;
//FramerateThrottler.onlyThrottleOnMac = true
